home
***
CD-ROM
|
disk
|
FTP
|
other
***
search
/
Software of the Month Club 1996 April
/
Software of the Month Club 1996 April.iso
/
mac
/
Education
/
LogoMation 1.1.1 ƒ
/
Examples
/
Towers of Hanoi
/
Towers of Hanoi
next >
Wrap
Text File
|
1995-10-14
|
756b
|
29 lines
// This program provides a visualization of the old Towers
// of Hanoi problem. It demonstrates recursion, and the
// use of library files. The library functions are in a
// file "Towers of Hanoi.lib", in the "Lib" folder.
Library ":Lib:Towers of Hanoi.lib"
// the main program //
/////////////////////////////////////
doPause = 0 // pause after each move, wait for CR
speed1 = 800
speed2 = 1600
thePause = 0.1
N = GetNumberOfTowers()
SetUp()
Move(N, 1, 3, 2)
// the recursive Move //
/////////////////////////////////////
Function Move(n, from, to, using)
If n = 1
MoveOne(1,from,to)
Else
Move(n-1, from, using, to)
MoveOne(n,from, to)
Move(n-1, using, to, from)